package gold.digger;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC357 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int countNumbersWithUniqueDigits(int n) {
            if (0 == n) return 1;
            if (1 == n) return 10;
            if (2 == n) return 91;
            if (10 < n) n = 10;
            int count = 9, multi = 9;
            for (int i = 1; i < n; i++) {
                multi *= count;
                --count;
            }

            return multi + countNumbersWithUniqueDigits(n - 1);
        }
    }

    public void run() {
        Solution solution = new Solution();
        System.out.println(solution.countNumbersWithUniqueDigits(3));
    }

    public static void main(String[] args) throws Exception {
        LC357 an = new LC357();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
